@echo off
setlocal

:: 设置 Redis 主节点和从节点的目录
set MASTER_DIR=.\master
set SLAVE1_DIR=.\slave1
set SLAVE2_DIR=.\slave2

:: 启动 Redis 主节点
echo Starting Redis Master Node...
start "" "%MASTER_DIR%\redis-server.exe" "%MASTER_DIR%\redis.windows.conf"

:: 启动 Redis 从节点 1
echo Starting Redis Slave Node 1...
start "" "%SLAVE1_DIR%\redis-server.exe" "%SLAVE1_DIR%\redis.windows.conf"

:: 启动 Redis 从节点 2
echo Starting Redis Slave Node 2...
start "" "%SLAVE2_DIR%\redis-server.exe" "%SLAVE2_DIR%\redis.windows.conf"

:: 等待 Redis 节点启动
echo Waiting for Redis nodes to start...
timeout /t 10 /nobreak

REM :: 创建 Redis 集群
REM echo Creating Redis Cluster...
REM "%MASTER_DIR%\redis-cli.exe" --cluster create 127.0.0.1:6379 127.0.0.1:6380 127.0.0.1:6381 --cluster-replicas 1

REM :: 启动客户端 1
REM echo Starting Redis Client 1...
REM start "" "%MASTER_DIR%\redis-cli.exe" -p 6379

REM :: 启动客户端 2
REM echo Starting Redis Client 2...
REM start "" "%MASTER_DIR%\redis-cli.exe" -p 6380

REM :: 启动客户端 3
REM echo Starting Redis Client 3...
REM start "" "%MASTER_DIR%\redis-cli.exe" -p 6381

echo Redis Cluster setup complete!

endlocal
pause